# List列表的定义
data_01 = ["nginx","tomcat","redis"],["apache","k8s"]
print(data_01[1][0])
# 列表解析
data_02 = [ i for i in range(1, 11) ]
print(data_02)
data_03 = [ "10.11.2.%s" % i for i in range(1, 11) ]
print(data_03)
for i in data_03:
    print("ping %s" % i)
data_04 = [ i ** 2 for i in range(1, 11) if i % 2 != 0 ]
print(data_04)
data_20 = ( i for i in range(1,90,2) if i % 3 == 0 and i % 7 == 0 )
data_21 = tuple(data_20)
print(data_21[1])

print("--------列表的常规操作-------")
data_05 = [ "redis", "mysql", "mongodb" ]
# 输出列表长度
print(len(data_05))
# 判断列表中是否有redis
print( "redis" in data_05 )

data_06 = [ ["docker", "23.2"], ["k8s", "1.29"] ]
print("----------")
print("docker" in data_06[0]) # False
print("docker" in data_06) # False
print( ["docker", "23.2"] in data_06) # True

# 索引操作 根据下标取值
data_07 = [ "redis", "mysql", "mongodb" ]
print(data_07[0])
print(data_07[-1])

data_08 = [ ["docker", "23.2"], ["k8s", "1.29"] ]
print(data_08[-1])
print(data_08[-1][-1])

# 列表：可变的数据类型 可以直接去修改它的数据
data_08[-1][-1] = "1.11"
print(data_08[-1])
print(data_08[-1][-1])

# append()  追加数据
data_09 = []
data_09.append("linux")
data_09.append("unix")
print(data_09)


print("--------------列表的遍历--------------")
data_10 = ["php", "pgp-fpm", "pgp-comman" ]
for i in data_10:
    print("yum isntall -y %s" % i)
da = len(data_10)
print(da)

data_11 = [ ["10.11.11.1", "admin", 22], ["10.12.1.1", "martin", 33], ["10.11.2.2", "jerry", 80] ]
# for i in data_11:
#     print("ssh %s@%s" % (i[1], i[0]))
# 每一个数据的子数据里的个数都是一样的
for i, j, p in data_11:
    print("ssh %s@%s -p %d" % (i, j, p))
